package com.bobo.service.impl;


import com.bobo.base.mybatis.ServiceImpl;
import com.bobo.mapper.TransportMapper;
import com.bobo.pojo.TransfeeFree;
import com.bobo.pojo.Transport;
import com.bobo.service.TransportService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TransportServiceImpl extends ServiceImpl<TransportMapper, Transport> implements TransportService {
    @Resource
    private TransportMapper transportMapper;
    @Override
    public Transport getTransportAndAllItems(Integer transportId) {
        // 根据运输ID获取运输信息，包括运输费用和运输城市信息
        Transport transport = transportMapper.getTransportAndTransfeeAndTranscity(transportId);
        // 检查是否找到运输信息，如果未找到则返回null
        if (transport == null) {
            return null;
        }
        // 根据运输ID获取免运费规则列表，包括免运费城市信息
        List<TransfeeFree> transfeeFrees = transportMapper.getTransfeeFreeAndTranscityFreeByTransportId(transportId);
        // 将免运费规则列表设置到运输信息对象中
        transport.setTransfeeFrees(transfeeFrees);
        // 返回包含免运费规则的运输信息对象
        return transport;
    }
}
